package com.backend.controller;

import com.backend.BackendApplication;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

@CrossOrigin
@RestController
@RequestMapping("/image")
public class ImageController {
    //加载图片
    @RequestMapping(value = "/movie",produces = MediaType.IMAGE_JPEG_VALUE)
    @ResponseBody
    public byte[] getModelImage(@RequestParam("id")String id) throws IOException {
        File file = new File(BackendApplication.MOVIE_PATH+id+".jpg");
        FileInputStream inputStream = new FileInputStream(file);
        byte[] bytes = new byte[inputStream.available()];
        inputStream.read(bytes, 0, inputStream.available());
        return bytes;
    }
}